//
//  JKCellRedPactet.m
//  chequanbao_ios
//
//  Created by 朱凯 on 2018/1/24.
//  Copyright © 2018年 com.itboye. All rights reserved.
//

#import "JKCellRedPactet.h"

@implementation JKCellRedPactet
{
    UILabel     *_reasonLabel;
    UILabel     *_dateLabel;
    UILabel     *_moneyLabel;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.backgroundColor = [UIColor whiteColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setupUI];
    }
    return self;
}
- (void)setupUI {
    
    _reasonLabel = [[UILabel alloc] init];
    _reasonLabel.text = @"原因";
    _reasonLabel.font = FONT(16);
    _reasonLabel.textAlignment = NSTextAlignmentLeft;
    _reasonLabel.textColor = [UIColor blackColor];
    [self.contentView addSubview:_reasonLabel];
    
    _moneyLabel = [[UILabel alloc] init];
    _moneyLabel.text = @"+12￥";

    _moneyLabel.font = FONT(16);
    _moneyLabel.textAlignment = NSTextAlignmentRight;
    _moneyLabel.textColor = [UIColor blackColor];
    [self.contentView addSubview:_moneyLabel];
    
    _dateLabel = [[UILabel alloc] init];
    _dateLabel.text = @"时间";
    _dateLabel.font = FONT(14);
    _dateLabel.textAlignment = NSTextAlignmentLeft;
    _dateLabel.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:_dateLabel];
    
    [_reasonLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@10);
        make.bottom.equalTo(self.mas_centerY).offset(-3);
    }];
    [_dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_reasonLabel);
        make.top.equalTo(self.mas_centerY).offset(3);
        make.width.equalTo(_reasonLabel);
    }];
    [_moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@-10);
        make.centerY.equalTo(self);
        make.left.greaterThanOrEqualTo(_reasonLabel.mas_right).offset(10);
    }];
}
- (void)setModel:(ByModelMinePoints *)model {
    
    _model = model;
    
    // 价格
    NSString *str = [NSString stringWithFormat:@"%.2f",(_model.after_score.floatValue - _model.before_score.floatValue)/100.0];
    if (_model.change_type.integerValue == 2) {
        str = [NSString stringWithFormat:@"+%@",str];
    }
    _moneyLabel.text = str;
 
    _reasonLabel.text = _model.reason;
    
    // 时间
    _dateLabel.text = [NSString stringWithFormat:@"%@",[NSDate getDateStringFromeNumber:[NSNumber numberWithInteger:[_model.create_time integerValue]]]];
}

@end
